<!DOCTYPE HTML>
<html>
<head>
    <include file="Common:header_include"/>
    <title>编辑医院</title>
</head>
<body>
<div class="pd-20">
    <form action="{:U('edit')}" method="post" class="form form-horizontal" id="form">
        <input name="id" type="hidden" value="{$data.id}">
         <div class="row cl">
            <label class="form-label col-1"><span class="c-red">*</span>医院名：</label>
            <div class="formControls col-7">
                <input type="text" class="input-text" placeholder="请输入" name="name" datatype="*" nullmsg="不能为空" value="{$data.name}">
            </div>
            <div class="col-4"></div>
          </div>
        <div class="row cl">
            <label class="form-label col-1"><span class="c-red"></span>封面图片：</label>
            <div class="formControls col-7">
                <input type="file" class="input-text" name="coverFile">
            </div>
            <div class="col-4">
                <if condition="$data['cover']">
                    已上传，<a href="javascript:void(0);" onclick="previewPictures('__UPS__{$data.cover}')" style="color: red;text-decoration: none;">预览</a>
                </if>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-1"><span class="c-red">*</span>省区：</label>
            <div class="formControls col-7">
                <span class="select-box">
                <select class="select Validform_error" size="1" name="provinceid" datatype="*" onchange="onchangeProvince($(this))" nullmsg="请选择">
                    <option value="" selected="" disabled="disabled">请选择</option>
                    <volist name=":getProvinceList(1)" id="v">
                        <option value="{$v.aerainfo_id}" <if condition="$data['provinceid'] eq $v['aerainfo_id']"> selected</if>>{$v.aerainfo_name}</option>
                        </option>
                    </volist>
                </select>
                </span>
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-1">市区：</label>
            <div class="formControls col-7">
                <span class="select-box">
                <select class="select Validform_error" size="1" name="cityid" onchange="onchangecity($(this))" id="city">
                    <option value="" selected="" disabled="disabled">请选择</option>
                    <volist name=":getProvinceList()" id="v">
                        <option value="{$v.aerainfo_id}" <if condition="$data['cityid'] eq $v['aerainfo_id']"> selected</if>>{$v['aerainfo_name']}</option>
                        </option>
                    </volist>
                </select>
                </span>
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-1">县区：</label>
            <div class="formControls col-7">
                <span class="select-box">
                <select class="select Validform_error" size="1" name="regionid"  id="district">
                    <option value="" selected="" disabled="disabled">请选择</option>
                     <volist name=":getProvinceList()" id="v">
                     <option value="{$v.aerainfo_id}" <if condition="$data['regionid'] eq $v['aerainfo_id']"> selected</if>>{$v['aerainfo_name']}</option>
                     </volist>
                </select>
                </span>
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-1">医院地址：</label>
            <div class="formControls col-7">
                <input type="text" class="input-text" placeholder="请输入" name="addr" value="{$data.addr}">
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-1">联系电话：</label>
            <div class="formControls col-7">
                <input type="text" class="input-text" placeholder="请输入" name="officephone"  value="{$data.officephone}">
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-1">联系人：</label>
            <div class="formControls col-7">
                <input type="text" class="input-text" placeholder="请输入" name="linkman" value="{$data.linkman}">
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-1">描述：</label>
            <div class="formControls col-7">
                <script id="content" name="description" type="text/plain" style="width:100%;height:400px;" >{:htmlspecialchars_decode($data['description'])}</script>
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <div class="col-9 col-offset-3">
                <input class="btn btn-primary radius" type="submit" value="提交">
            </div>
        </div>
    </form>
</div>
<include file="Common:footer_include"/>
</body>
<script type="text/javascript">
    $(function () {
        var ue = UE.getEditor('content');
    });
    function onchangeProvince(jqObj){
        var province_id = jqObj.val();
        var citycheck = $('#city');
        citycheck.html('');
        $.ajax({
            url: '{:U("Hospitalinfo/getCityListJson")}?province_id=' + province_id,
            type: 'post',
            enctype: 'multipart/form-data',
            success: function (data) {
                $.each(data, function (i, item) {
                    citycheck.append('<option value="' + item.aerainfo_id + '" >' + item.aerainfo_name + '</option>');
//                    var diseaseHtml="<div class='skin-minimal check-box' style='width: 200px;margin-top: 5px'> <div class='check-box'> <input type='checkbox' name='disease_id[]' checked value='"+item.id+"'>"+item.title+"</div> </div>";
//                    diseaseBox.append(diseaseHtml);
                });
                onchangecity(citycheck)
            },
        });
    }
    function onchangecity(jqObj){
        var city_id = jqObj.val();
        var districtcheck = $('#district');
        var ajaxurl='{:U("Hospitalinfo/getDistrictJson")}?city_id=' + city_id;
        districtcheck.html('');
        $.ajax({
            url:ajaxurl ,
            type: 'post',
            enctype: 'multipart/form-data',
            success: function (data) {
                $.each(data, function (i, item) {
                    districtcheck.append('<option value="' + item.aerainfo_id + '" >' + item.aerainfo_name + '</option>');
//                    var diseaseHtml="<div class='skin-minimal check-box' style='width: 200px;margin-top: 5px'> <div class='check-box'> <input type='checkbox' name='disease_id[]' checked value='"+item.id+"'>"+item.title+"</div> </div>";
//                    diseaseBox.append(diseaseHtml);
                });
            }
        });
    }

</script>
 </html>